export default {
  mounted () {
    this.initEvent()
  },
  destroyed () {
    window.removeEventListener('scroll', this.scroll)
  },
  methods: {
    initEvent () {
      window.addEventListener('scroll', this.scroll)
    },
    scroll () {
      const windowHeight = window.innerHeight
      const bodyHeight = document.body.clientHeight
      const scrollY = window.scrollY
      if (scrollY + windowHeight === bodyHeight) {
        this.onReachBottom()
      }
    }
  }
}
